﻿<%@ WebHandler Language="C#" Class="houseCensorNew" %>

using System;
using System.Web;
using Chenxin.Lib.Utility;
using System.Data;
using System.Text;

public class houseCensorNew : AjaxHandlerBase
{
    public houseCensorNew()
    {
        htTypePermit.Add("del", Constants.Permit_DelHouse_Base);
        htTypePermit.Add("export", Constants.Permit_ExportHouseCensor);
        htTypePermit.Add("getcustomerlist", Constants.Permit_CustomerBak_View);        
    }
    
    public override void RequestProcess(HttpContext context)
    {

        context.Response.ContentType = "text/plain";
        context.Response.Buffer = true;
        context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
        context.Response.AddHeader("pragma", "no-cache");
        context.Response.AddHeader("cache-control", "");
        context.Response.CacheControl = "no-cache";

        if (context.Request["op"] != null)
        {
            switch (context.Request["op"].ToLower())
            {
                case "getlist":
                    GetList(context);
                    break;
                case "gethousetracelist":
                    GetHouseTraceList(context);
                    break;
                case "del":
                    Del(context);
                    break;
                case "export":
                    context.Response.Write("{success:'1',msg:'',data:''}");
                    break;
                case "getcustomerlist":
                    GetCustomerList(context);
                    break;
                default:
                    break;
            }
        }
    }

    private void GetCustomerList(HttpContext context)
    {
        string customerid = context.Request["customerid"];
        string houseid = context.Request["houseid"];
        int iPageIndex = (string.IsNullOrEmpty(context.Request["pageindex"])) ? 1 : int.Parse(context.Request["pageindex"]) + 1;//页码
        int iPageSize = (string.IsNullOrEmpty(context.Request["pagesize"])) ? 30 : int.Parse(context.Request["pagesize"]);//页记录数

        StringBuilder sb = new StringBuilder();
        sb.AppendFormat("CustomerId='{0}' or customerid in (select customerid from House_CustomerRelationHistory where houseid='{1}' and CustomerId<>'{0}') ", customerid,houseid);

        DataSet list = Chenxin.Lib.House.DAL.Customer_BaseInfo_BakCol.GetList(iPageIndex, iPageSize, "adddate desc", "Customer_BaseInfo_BakCol", sb.ToString(), "*", "*", true);

        context.Response.Write(string.Format("{{success:'1',msg:'',data:{{count:{0},{1}}}}}", list.Tables[1].Rows[0][0], Chenxin.Lib.Utility.JsonHelp.Convert2Json(list.Tables[0])));
    }
    
    
    /// <summary>
    /// 删除一条记录
    /// </summary>
    /// <param name="context"></param>
    private void Del(HttpContext context)
    {
        try
        {
            if (context.Request["modelid"] != null)
            {
                Chenxin.Lib.House.Entity.House_BaseInfo model = Chenxin.Lib.House.DAL.House_BaseInfo.GetModel(new Guid(context.Request["modelid"]));
                if (model == null)
                {
                    context.Response.Write("{success:'0',msg:'获取数据记录出错，记录不存在！！',data:''}");
                    return;
                }

                model.Status = -10;
                model.UpdateTime = DateTime.Now;
                Chenxin.Lib.House.DAL.House_BaseInfo.Update(model);
                //清除缓存
                string strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_HOUSEINFO, model.HouseId);
                Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
                cs.Delete(strCachKey);
                context.Response.Write("{success:'1',msg:'删除成功！',data:''}");
            }
            else
            {
                context.Response.Write("{success:'0',msg:'删除失败,请选择一条记录！',data:''}");
            }
        }
        catch
        {
            context.Response.Write("{success:'0',msg:'删除失败！',data:''}");
        }
    }
    /// <summary>
    /// 根据参数中的房源ID查询房源跟单数据;
    /// 返回Json数据：{count:'30',data:'abc'}
    /// </summary>
    /// <param name="context"></param>
    private void GetHouseTraceList(HttpContext context)
    {
        Guid houseId = (string.IsNullOrEmpty(context.Request["houseid"])) ? Guid.Empty : new Guid(context.Request["houseid"]);
        string responseJson = "";
        try
        {
            if (houseId == Guid.Empty)
            {
                responseJson = string.Format("{{success:'0',msg:'{0}',data:''}}", "参数错误，房源标识丢失");
                context.Response.Write(responseJson);
                return;
            }

            int iPageIndex = (string.IsNullOrEmpty(context.Request["pageindex"])) ? 1 : int.Parse(context.Request["pageindex"]) + 1;//页码
            int iPageSize = (string.IsNullOrEmpty(context.Request["pagesize"])) ? 30 : int.Parse(context.Request["pagesize"]);//页记录数
            string fieldlist = "*";
            string fieldtablelist = "*";
            string orderfield = "House_TraceInfo.TraceTime desc";
            string strwhere = string.Format("(houseId='{0}' AND IsHide = 0 AND Status = 0)", houseId);

            System.Data.DataSet dshousetracelist = null;
            if (iPageIndex == 1)
            {
                //分页第一页从缓存中读取
                Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
                string strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.HOUSE_TRACE + "." + iPageSize.ToString(), houseId);

                dshousetracelist = cs.GetDataSet(strCachKey);
                if (!cs.Hit)
                {
                    //若未命中。从查询数据库中读取
                    dshousetracelist = Chenxin.Lib.House.DAL.House_TraceInfo.GetList(
                        iPageIndex, iPageSize, orderfield, "House_TraceInfo", strwhere, fieldlist, fieldtablelist, true);

                    if (dshousetracelist != null && dshousetracelist.Tables[0].Rows.Count != 0)
                        cs.Set(strCachKey, dshousetracelist, DateTime.Now.AddMinutes(10));
                }
            }
            else
            {
                dshousetracelist = Chenxin.Lib.House.DAL.House_TraceInfo.GetList(
                iPageIndex, iPageSize, orderfield, "House_TraceInfo", strwhere, fieldlist, fieldtablelist, true);
            }

            int count = (int)dshousetracelist.Tables[1].Rows[0][0];

            StringBuilder html = new StringBuilder();
            html.Append("<table class=\"tabsorternew\" cellspancing=\"1\">");
            html.AppendFormat("<thead><tr><th>跟单内容</th><th style=\"width:100px;\">跟单人/跟单时间</th></tr></thead><tbody>");
            foreach (DataRow dr in dshousetracelist.Tables[0].Rows)
            {
                html.AppendFormat("<tr><td>{0}</td><td>{1}/{2}/{3:yyyy-MM-dd}</td></tr>", DatasetHelper.GetValue(dr, "TraceContext", ""), DatasetHelper.GetValue(dr, "Tractor", "-"), DatasetHelper.GetValue(dr, "Depart", "-"), Convert.ToDateTime(DatasetHelper.GetValue(dr, "TraceTime", "-")));                
            }
            html.Append("</tbody></table>");

            dshousetracelist.Dispose();
            dshousetracelist = null;
            responseJson = string.Format("{{success:'1',msg:'{0}',data:{{count:'{1}',data:'{2}'}}}}", "成功", count, html.ToString());
            context.Response.Write(responseJson);
        }
        catch (Exception ex)
        {
            responseJson = string.Format("{{success:'0',msg:'{0}',data:''}}", "未知错误：" + ex.Message);
            context.Response.Write(responseJson);
            return;
        }
    }
    


    /// <summary>
    /// 返回房源列表；
    /// 根据查询参数生成查询条件1,根据权限设定生成查询条件2；
    /// 返回Json数据：{count:'30',data:'abc'}
    /// </summary>
    /// <param name="context"></param>
    private void GetList(HttpContext context)
    {
        string responseJson = "";
        try
        {
            int iPageIndex = (string.IsNullOrEmpty(context.Request["pageindex"])) ? 1 : int.Parse(context.Request["pageindex"]) + 1;//页码
            int iPageSize = (string.IsNullOrEmpty(context.Request["pagesize"])) ? 30 : int.Parse(context.Request["pagesize"]);//页记录数
            string strCommunity = context.Request["community"];//楼盘
            string strCommunityId = context.Request["communityid"];//楼盘
            string strRegion = context.Request["region"];//区域；
            string strBlock = context.Request["block"];//板块
            int iStatus = string.IsNullOrEmpty(context.Request["status"]) ? 1000 : int.Parse(context.Request["status"]);//房源状态
            int iBussines = string.IsNullOrEmpty(context.Request["business"]) ? 1000 : int.Parse(context.Request["business"]);//交易类型
            string strHouseUse = context.Request["houseuse"];//房屋用途
            string strBuildingType = context.Request["buildingtype"];//建筑类型
            string strLowPrice = context.Request["lowprice"];//最低价
            string strHightPrice = context.Request["heightprice"];//最高价
            string strKeyword = context.Request["keyword"];//智能
            string strUserCode = context.Request["usercode"];//工号
            string strDayType = context.Request["daytype"];//日期类型
            string strDayBegin = context.Request["daybegin"];//开始日期
            string strDayEnd = context.Request["dayend"];//结束日期
            string strOrderField = context.Request["sort"];//排序字段名

            string isPhoneProtected = context.Request["protected"];
            string isMarked = context.Request["marked"];
            string buildingName = context.Request["BuildingName"];
            string room = context.Request["Room"];
            string model_Room = context.Request["houseroom"];
            string model_Hall = context.Request["househall"];
            string buildingAreaStart = context.Request["area_start"];
            string buildingAreaEnd = context.Request["area_end"];
            string fitment = context.Request["Fitment"];
            string isHavekey = context.Request["haskey"];
            string floorStart = context.Request["floor_start"];
            string floorEnd = context.Request["floor_end"];
            string priceStyle = context.Request["pricetype"];
            string timetrace = context.Request["timetrace"];
            
            Guid cityId = (string.IsNullOrEmpty(context.Request["cityid"])) ? Guid.Empty : new Guid(context.Request["cityid"]);
            Guid companyId = (string.IsNullOrEmpty(context.Request["companyid"])) ? Guid.Empty : new Guid(context.Request["companyid"]);
            Guid areaId = (string.IsNullOrEmpty(context.Request["areaid"])) ? Guid.Empty : new Guid(context.Request["areaid"]);
            Guid departId = (string.IsNullOrEmpty(context.Request["departid"])) ? Guid.Empty : new Guid(context.Request["departid"]);
            Guid userId = (string.IsNullOrEmpty(context.Request["userid"])) ? Guid.Empty : new Guid(context.Request["userid"]);

            string fieldlist = " Cur_Floor,Total_Floor,Model_Toilet,Model_Room,Model_Hall,SalePrice_U,IsMarked, IsTrust, IsHavekey, IsHot, IsProtectPhone, Status, Region, Community, " +
                               "CommunityId, BuildingId, BuildingName, Room, BusinessKind, Kind, BuildingArea, SalePrice_T, RentPrice," +
                               "OprDepartId, OprDepart, OprPersonId, OprPerson, ServiceTime,Adddate,HouseId,CustomerName,CustTel1";

            string tablefieldlist = " Cur_Floor,Total_Floor,Model_Toilet,Model_Room,Model_Hall,SalePrice_U,IsMarked, IsTrust, IsHavekey, IsHot, IsProtectPhone, " +
                                    "case Status when '10' then '有效' when '-1' then '无效' when '20' then '暂缓' when 30 then '封盘' when -10 then '删除' end as Status," +
                                    "Region, Community,case BusinessKind when '20' then '出租' when '10' then '出售' else '租售' end as BusinessKind,BusinessKind as Kind, " +
                                    "CommunityId, BuildingId, BuildingName, Room, BuildingArea, SalePrice_T, floor(RentPrice) as RentPrice ," +
                                    "OprDepartId, OprDepart, OprPersonId, OprPerson, ServiceTime,Adddate,HouseId,CustomerName,(select isnull(Mobile,'')+'/'+isnull(Phone,'') from Customer_BaseInfo where Customer_BaseInfo.CustomerId=House_BaseInfo.CustomerId) as CustTel1";
 
            System.Text.StringBuilder sb1 = new System.Text.StringBuilder();


            if ("10".Equals(timetrace))
            {
                sb1.Append(" and ((DATEADD(hh,48,(House_BaseInfo.Adddate ))) < (select min(House_TraceInfo.TraceTime) from House_TraceInfo where House_TraceInfo.TractorId=House_BaseInfo.OprPersonId and House_TraceInfo.HouseId=House_BaseInfo.HouseId and House_TraceInfo.status =0)  ");
                sb1.Append(" OR ((select min(House_TraceInfo.TraceTime) from House_TraceInfo where House_TraceInfo.TractorId=House_BaseInfo.OprPersonId and House_TraceInfo.HouseId=House_BaseInfo.HouseId and status =0) is null and ((DATEADD(hh,48,(House_BaseInfo.Adddate)) < getdate())))) ");
            }
            if (!string.IsNullOrEmpty(context.Request["customer_tel"]))
            {
                sb1.AppendFormat(" And (CustomerId in (select CustomerId from dbo.Customer_BaseInfo where Mobile='{0}' or Phone like '%{0}%'))", context.Request["customer_tel"]);
            }

            //楼盘
            if (!string.IsNullOrEmpty(strCommunityId))
            {
                sb1.AppendFormat(" AND (CommunityId ='{0}')", strCommunityId);
            }
            else
            {
                if (!string.IsNullOrEmpty(strCommunity))
                    sb1.AppendFormat(" AND (Community Like '%{0}%')", strCommunity);
            }

            System.Text.StringBuilder sbRegion = new StringBuilder();
            bool bHaveRegion = false;
            //区域
            if (!string.IsNullOrEmpty(strRegion))
            {
                bHaveRegion = true;
                string[] str = strRegion.Split(',');
                sbRegion.AppendFormat(" AND ((");
                for (int i = 0; i < str.Length; i++)
                {
                    if (string.IsNullOrEmpty(str[i]))
                        continue;
                    if (i == 0)
                    {
                        sbRegion.AppendFormat(" Region = '{0}' ", str[i]);
                    }
                    else
                    {
                        sbRegion.AppendFormat(" OR Region = '{0}' ", str[i]);
                    }
                }
                sbRegion.AppendFormat(" ) ");
            }
            //板块
            if (!string.IsNullOrEmpty(strBlock))
            {
                string[] str = strBlock.Split(',');
                if (sbRegion.Length > 0)
                    sbRegion.AppendFormat(" OR (");
                else
                    sbRegion.AppendFormat(" AND (");

                for (int i = 0; i < str.Length; i++)
                {
                    if (string.IsNullOrEmpty(str[i]))
                        continue;
                    if (i == 0)
                    {
                        sbRegion.AppendFormat(" Block = '{0}' ", str[i]);
                    }
                    else
                    {
                        sbRegion.AppendFormat(" OR Block = '{0}' ", str[i]);
                    }
                }
                sbRegion.AppendFormat(" ) ");

            }

            if (bHaveRegion) sbRegion.AppendFormat(" ) ");
            if (sbRegion.Length > 0) sb1.Append(sbRegion.ToString());
            //状态
            if (iStatus != 1000)
                sb1.AppendFormat(" AND (Status = {0})", iStatus);
            else
                sb1.Append(" AND (Status > -10 AND Status <30)");
            //交易
            if (iBussines != 1000)
                sb1.AppendFormat(" AND (BusinessKind = {0} OR BusinessKind = 30)", iBussines);
            //智能
            if (!string.IsNullOrEmpty(strKeyword))
            {
                string[] keyList;
                if (strKeyword.IndexOf(" ") != -1)
                {
                    keyList = strKeyword.Split(' ');
                }
                else
                {
                    keyList = strKeyword.Split(',');
                }
                StringBuilder _key = new StringBuilder();
                foreach (string tkey in keyList)
                {
                    _key.AppendFormat(" or (DetailAddress Like '%{0}%' Or HouseCode Like '%{0}%' or Community Like '%{0}%')", tkey);
                }
                sb1.AppendFormat(" and (1=0 {0})", _key);
                //sb1.AppendFormat(" AND (DetailAddress Like '%{0}%' Or HouseCode Like '%{0}%' or Community Like '%{0}%')", strKeyword);
            }
            //号
            if (!string.IsNullOrEmpty(buildingName))
                sb1.AppendFormat(" AND (BuildingName Like '%{0}%')", buildingName);
            //室
            if (!string.IsNullOrEmpty(room))
                sb1.AppendFormat(" AND (Room='{0}')", room);
            //价格
            if (!string.IsNullOrEmpty(strLowPrice) && !string.IsNullOrEmpty(strHightPrice))
            {
                decimal lprice = Convert.ToDecimal(strLowPrice);
                decimal hprice = Convert.ToDecimal(strHightPrice);
                //总价
                if ("t_price".Equals(priceStyle))
                {
                    sb1.AppendFormat(" AND (((SalePrice_T <={0} and SalePrice_T >={1}) and BusinessKind=30) or ((SalePrice_T <={0}) and (SalePrice_T >={1}) and BusinessKind=10) or ((RentPrice<={0})  and (RentPrice>={1}) and BusinessKind=20))", hprice * 10000, lprice * 10000);
                }
                else
                {
                    sb1.AppendFormat(" AND (SalePrice_U <={0} and SalePrice_U >={1})", hprice, lprice);
                }
            }
            else if (!string.IsNullOrEmpty(strLowPrice) && string.IsNullOrEmpty(strHightPrice))
            {
                decimal lprice = Convert.ToDecimal(strLowPrice);
                //总价
                if ("t_price".Equals(priceStyle))
                {
                    sb1.AppendFormat(" AND (((SalePrice_T >={0}) and BusinessKind=30) or (SalePrice_T >={0} and BusinessKind=10) or (RentPrice>={0} and BusinessKind=20))", lprice * 10000);
                }
                else
                {
                    sb1.AppendFormat(" AND (SalePrice_U >={0})", lprice);
                }
            }
            else if (!string.IsNullOrEmpty(strHightPrice) && string.IsNullOrEmpty(strLowPrice))
            {
                decimal hprice = Convert.ToDecimal(strHightPrice);
                //总价
                if ("t_price".Equals(priceStyle))
                {
                    sb1.AppendFormat(" AND (((SalePrice_T <={0}) and BusinessKind=30) or (SalePrice_T <={0} and BusinessKind=10) or (RentPrice<={0} and BusinessKind=20))", hprice * 10000);
                }
                else
                {
                    sb1.AppendFormat(" AND (SalePrice_U <={0})", hprice);
                }
            }
            //房型
            if (!string.IsNullOrEmpty(model_Room))
            {
                string[] str = model_Room.Split(',');
                sb1.AppendFormat(" AND (");
                for (int i = 0; i < str.Length; i++)
                {
                    if (string.IsNullOrEmpty(str[i]))
                        continue;
                    if (i == 0)
                    {
                        sb1.AppendFormat(" Model_Room = '{0}' ", str[i]);
                    }
                    else
                    {
                        sb1.AppendFormat(" OR Model_Room = '{0}' ", str[i]);
                    }
                }
                sb1.AppendFormat(" ) ");
            }
            if (!string.IsNullOrEmpty(model_Hall))
            {
                string[] str = model_Hall.Split(',');
                sb1.AppendFormat(" AND (");
                for (int i = 0; i < str.Length; i++)
                {
                    if (string.IsNullOrEmpty(str[i]))
                        continue;
                    if (i == 0)
                    {
                        sb1.AppendFormat(" Model_Hall = '{0}' ", str[i]);
                    }
                    else
                    {
                        sb1.AppendFormat(" OR Model_Hall = '{0}' ", str[i]);
                    }
                }
                sb1.AppendFormat(" ) ");
            }
            //日期
            if (!string.IsNullOrEmpty(strDayType))
            {
                if (!string.IsNullOrEmpty(strDayBegin))
                {
                    sb1.AppendFormat(" AND ({0} >= '{1}')", (strDayType == "10") ? "ServiceTime" : "Adddate", strDayBegin);
                }

                if (!string.IsNullOrEmpty(strDayEnd))
                {
                    sb1.AppendFormat(" AND ({0} <= '{1}')", (strDayType == "10") ? "ServiceTime" : "Adddate", DateTime.Parse(strDayEnd).AddDays(1));
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(strDayBegin))
                {
                    sb1.AppendFormat(" AND ({0} >= '{1}')", "Adddate", strDayBegin);
                }

                if (!string.IsNullOrEmpty(strDayEnd))
                {
                    sb1.AppendFormat(" AND ({0} <= '{1}')", "Adddate", DateTime.Parse(strDayEnd).AddDays(1));
                }
            }
            //面积
            if (!string.IsNullOrEmpty(buildingAreaStart))
                sb1.AppendFormat(" AND (BuildingArea >= {0})", buildingAreaStart);
            if (!string.IsNullOrEmpty(buildingAreaEnd))
                sb1.AppendFormat(" AND (BuildingArea <= {0})", buildingAreaEnd);
            //用途
            if (!string.IsNullOrEmpty(strHouseUse))
                sb1.AppendFormat(" AND (HouseUse = '{0}')", strHouseUse);
            //类型
            if (!string.IsNullOrEmpty(strBuildingType))
                sb1.AppendFormat(" AND (BuildingType = '{0}')", strBuildingType);
            //备案
            if (!string.IsNullOrEmpty(isMarked))
                sb1.AppendFormat(" AND (IsMarked = {0})", isMarked);
            //保护
            if (!string.IsNullOrEmpty(isPhoneProtected))
            {
                if ("1".Equals(isPhoneProtected))
                    sb1.AppendFormat(" AND (IsProtectPhone = {0}) ", 1);
                else if ("2".Equals(isPhoneProtected))
                {
                    sb1.AppendFormat(" AND (IsProtectPhone = {0} AND IsAutoProPhone = {1}) ", 1, 1);
                }
                else if ("3".Equals(isPhoneProtected))
                {
                    sb1.AppendFormat(" AND (IsProtectPhone = {0} AND IsAutoProPhone = {1}) ", 1, 0);
                }
                else
                {
                    sb1.AppendFormat(" AND (IsProtectPhone = {0}) ", 0);
                }

            }
            //装修
            if (!string.IsNullOrEmpty(fitment))
                sb1.AppendFormat(" AND (Fitment = '{0}')", fitment);
            //钥匙
            if (!string.IsNullOrEmpty(isHavekey))
            {
                if ("10".Equals(isHavekey))
                    sb1.AppendFormat(" AND (IsHavekey = '{0}')", 1);
                else
                    sb1.AppendFormat(" AND (IsHavekey = '{0}')", 0);
            }
            //工号
            if (!string.IsNullOrEmpty(strUserCode))
            {
                Chenxin.Lib.Passport.Entity.Hr_UserInfo hr = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetEntityByCode(strUserCode);
                if (hr != null)
                {
                    sb1.AppendFormat(" AND OprPersonId='{0}'", hr.UserId);
                }
                else
                {
                    sb1.AppendFormat(" AND (1=0)");
                }
                hr = null;
            }
            //楼层
            if (!string.IsNullOrEmpty(floorStart))
                sb1.AppendFormat(" AND (Cur_Floor >= {0})", floorStart);
            if (!string.IsNullOrEmpty(floorEnd))
                sb1.AppendFormat(" AND (Cur_Floor <= {0})", floorEnd);

            //描述：快速搜索参数拼接
            if (context.Request["quicktype"] != null)
            {
                switch (context.Request["quicktype"])
                {
                    case "owner"://我的房源
                        sb1.AppendFormat(" And(OprPersonId='{0}')", CurrentUserInfo.UserId);
                        break;
                    case "depart"://本店房源
                        sb1.AppendFormat(" And(OprDepartId='{0}')", CurrentUserInfo.DepartId);
                        break;
                    case "today"://本日房源
                        sb1.AppendFormat(" And (datediff(d,Adddate,'{0}')=0)", DateTime.Now);
                        break;
                    case "thismonth"://本月房源
                        sb1.AppendFormat(" And (datediff(m,Adddate,'{0}')=0)", DateTime.Now);
                        break;
                    case "key"://要是房源
                        sb1.Append(" And (IsHavekey='1')");
                        break;
                    case "favor":// 我的收藏
                        sb1.AppendFormat(" And (HouseId in (select FavorId from Personal_FavorsInfo where FavorPersonId = '{0}' and FavorType = 0 ))", CurrentUserInfo.UserId);
                        break;
                }
            }

            //级联//////////////////////////////////////////////////////
            if (userId != Guid.Empty)
                sb1.AppendFormat(" AND (OprPersonId = '{0}') ", userId);
            else if (departId != Guid.Empty)
                sb1.AppendFormat(" AND (OprDepartId = '{0}')", departId);
            else if (areaId != Guid.Empty)
            {
                Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo item = null;
                string strCachkey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPARTMENT, areaId);
                Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
                item = cs.GetObject<Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo>(strCachkey);
                if (!cs.Hit)
                {
                    item = Chenxin.Lib.Hr.DAL.Hr_DepartmentInfo.GetModel(areaId);
                    if (item != null) cs.Set(strCachkey, item, DateTime.Now.AddDays(1));
                }

                if (item == null) context.Response.Write(string.Format("{{success:'0',msg:'{0}',data:''}}", "获取商圈或分类数据丢失"));

                sb1.AppendFormat(" AND (OprDepartId in (select departId from v_Hr_DepartmentInfo where DepartSrc like '{0}%'))", item.DepartSrc);
            }
            else if (companyId != Guid.Empty)
                sb1.AppendFormat(" AND (CompanyId = '{0}')", companyId);
            else if (cityId != Guid.Empty)
                sb1.AppendFormat(" AND (CityId = '{0}')", cityId);
            else
                sb1.AppendFormat(" AND (CompanyId = '{0}')", CurrentUserInfo.CompanyId);


            //判断权限范围/////////////////////////////////////////////
            System.Text.StringBuilder sb2 = new System.Text.StringBuilder();

            bool IsPublicHouse;
            bool IsPrivateHouse;
            //公盘房源权限
            IsPublicHouse = CurrentUserInfo.ContainsPermit(Constants.Permit_ViewPublicHouse);
            //私盘房源权限
            IsPrivateHouse = CurrentUserInfo.ContainsPermit(Constants.Permit_ViewPrivateHouse);

            //所有房源权限
            if (CurrentUserInfo.ContainsPermit(Constants.Permit_ViewAllHouse))
            {
                //所有权限
                if (IsPublicHouse && IsPrivateHouse)
                {
                    sb2.Append(" 1=1 ");
                }
                //公盘房源权限
                else if (IsPublicHouse)
                {
                    sb2.AppendFormat(" (IsProtectHouse=0 Or OprPersonId = '{0}') ", CurrentUserInfo.UserId);
                }
                //私盘房源权限
                else if (IsPrivateHouse)
                {
                    sb2.AppendFormat(" (IsProtectHouse=1 Or OprPersonId = '{0}') ", CurrentUserInfo.UserId);
                }
                //无房源访问权限
                else
                {
                    sb2.AppendFormat(" OprPersonId = '{0}' ", CurrentUserInfo.UserId);
                }
            }
            //城市房源权限
            else if (CurrentUserInfo.ContainsPermit(Constants.Permit_ViewCityHouse))
            {
                //所有权限
                if (IsPublicHouse && IsPrivateHouse)
                {
                    sb2.Append("(");
                    sb2.AppendFormat(" CityId='{0}' ", CurrentUserInfo.CityId.ToString());
                    sb2.AppendFormat(" Or OprPersonId = '{0}'", CurrentUserInfo.UserId);
                    sb2.Append(")");
                }
                //公盘房源权限
                else if (IsPublicHouse)
                {
                    sb2.Append("(");
                    sb2.AppendFormat(" (CityId='{0}' And IsProtectHouse=0) ", CurrentUserInfo.CityId.ToString());
                    sb2.AppendFormat(" Or OprPersonId = '{0}'", CurrentUserInfo.UserId);
                    sb2.Append(")");
                }
                //私盘房源权限
                else if (IsPrivateHouse)
                {
                    sb2.Append("(");
                    sb2.AppendFormat(" (CityId='{0}' And IsProtectHouse=1) ", CurrentUserInfo.CityId.ToString());
                    sb2.AppendFormat(" Or OprPersonId = '{0}'", CurrentUserInfo.UserId);
                    sb2.Append(")");
                }
                //无房源访问权限
                else
                {
                    sb2.AppendFormat("(OprPersonId = '{0}')", CurrentUserInfo.UserId);
                }
            }
            //公司房源权限
            else if (CurrentUserInfo.ContainsPermit(Constants.Permit_ViewCompanyHouse))
            {
                //所有权限
                if (IsPublicHouse && IsPrivateHouse)
                {
                    sb2.Append("(");
                    sb2.AppendFormat(" CompanyId='{0}' ", CurrentUserInfo.CompanyId.ToString());
                    sb2.AppendFormat(" Or OprPersonId = '{0}'", CurrentUserInfo.UserId);
                    sb2.Append(")");
                }
                //公盘房源权限
                else if (IsPublicHouse)
                {
                    sb2.Append("(");
                    sb2.AppendFormat(" (CompanyId='{0}' And IsProtectHouse=0) ", CurrentUserInfo.CompanyId.ToString());
                    sb2.AppendFormat(" Or OprPersonId = '{0}'", CurrentUserInfo.UserId);
                    sb2.Append(")");
                }
                //私盘房源权限
                else if (IsPrivateHouse)
                {
                    sb2.Append("(");
                    sb2.AppendFormat(" (CompanyId='{0}' And IsProtectHouse=1) ", CurrentUserInfo.CompanyId.ToString());
                    sb2.AppendFormat(" Or OprPersonId = '{0}'", CurrentUserInfo.UserId);
                    sb2.Append(")");
                }
                //无房源访问权限
                else
                {
                    sb2.AppendFormat("(OprPersonId = '{0}')", CurrentUserInfo.UserId);
                }
            }
            //部门房源权限 
            else if (CurrentUserInfo.ContainsPermit(Constants.Permit_ViewDepartHouse))
            {
                sb2.Append("(EXISTS(");
                sb2.Append("Select 1 from v_Struct_UserDepartRelation M ");
                sb2.AppendFormat("WHERE (OprDepartId = M.Departid AND  M.Userid= '{0}') ", CurrentUserInfo.UserId);
                sb2.Append("AND ((IsProtectHouse = 1 AND M.ViewPrivHouse =1) OR ");
                sb2.Append("(IsProtectHouse = 0 AND M.ViewPubHouse =1))");
                sb2.AppendFormat(") Or (OprPersonId = '{0}'))", CurrentUserInfo.UserId);
            }
            //个人房源权限
            else
            {
                sb2.AppendFormat("(OprPersonId = '{0}')", CurrentUserInfo.UserId);
            }

            if (sb1.ToString().Trim() != "") sb2.Append(sb1);


            string order = string.Empty;
            if (string.IsNullOrEmpty(strOrderField))
            {
                order = " Adddate DESC ";
            }
            else
            {
                order = " " + strOrderField;
            }
            System.Data.DataSet dshouselist = Chenxin.Lib.House.DAL.House_BaseInfo.GetList(
                iPageIndex, iPageSize, order, "House_BaseInfo", sb2.ToString(), fieldlist, tablefieldlist, true);

            int count = (int)dshouselist.Tables[1].Rows[0][0];

            string strHtml = "";
            string[] key = strOrderField.Split(' ');
   
            string canexport = context.Request["canexport"];
            System.Text.StringBuilder head = new System.Text.StringBuilder();
            if ("10".Equals(canexport))
            {
                head.Append("{");
                head.AppendFormat("icon:{{width:{0},head:'',inField:false}},", 40);
                head.AppendFormat("Region:{{width:{0},head:'{1}',sortable:true}},", 40, "区域");
                head.AppendFormat("Status:{{width:{0},head:'{1}',sortable:true}},", 40, "状态");
                head.AppendFormat("Name:{{width:{0},head:'{1}',sortable:true,sortField:'{2}'}},", 200, "楼盘/门号/房号", "Community,BuildingName,Room");
                head.AppendFormat("BusinessKind:{{width:{0},head:'{1}',sortable:true}},", 40, "交易");
                head.AppendFormat("BuildingArea:{{width:{0},head:'{1}',sortable:true}},", 55, "面积");
                head.AppendFormat("SalePrice_U:{{width:{0},head:'{1}',sortable:true}},", 60, "单价(元)");
                head.AppendFormat("SalePrice_T:{{width:{0},head:'{1}',sortable:true,sortField:'{2}'}},", 65, "总价", "SalePrice_T");
                head.AppendFormat("RentPrice:{{width:{0},head:'{1}',sortable:true,sortField:'{2}'}},", 65, "租价", "SalePrice_T");
               // head.AppendFormat("HouseStyle:{{width:{0},head:'{1}',sortable:true,sortField:'{2}'}},", 40, "房型", "Model_Room,Model_Hall,Model_Toilet");
               // head.AppendFormat("Floor:{{width:{0},head:'{1}',sortable:true,sortField:'{2}'}},", 50, "楼层", "Cur_Floor");
                head.AppendFormat("OprDepart:{{width:{0},head:'{1}',sortable:true}},", 70, "部门");
                head.AppendFormat("OprPerson:{{width:{0},head:'{1}',sortable:true}},", 60, "业务员");
                head.AppendFormat("CustomerName:{{width:{0},head:'{1}',sortable:true}},", 70, "客户姓名");
                //head.AppendFormat("CustTel1:{{width:{0},head:'{1}',sortable:true}},", 60, "客户电话");
                if ("servicetime".Equals(key[0].ToLower()))
                {
                    head.AppendFormat("ServiceTime:{{width:{0},head:'{1}',sortable:true}}", 70, "跟单时间", true);
                }
                else
                {
                    head.AppendFormat("Adddate:{{width:{0},head:'{1}',sortable:true}}", 70, "建档时间", true);
                }
                head.Append("}");
                if (!SubGetHouseListHtml(dshouselist, key[0], out strHtml))
                {
                    responseJson = string.Format("{{success:'0',msg:'{0}',data:''}}", "生成HTML错误");
                }
            }
            else
            {
                head.Append("{");
                head.AppendFormat("icon:{{width:{0},head:'',inField:false}},", 40);
                head.AppendFormat("Region:{{width:{0},head:'{1}',sortable:true}},", 40, "区域");
                head.AppendFormat("Status:{{width:{0},head:'{1}',sortable:true}},", 40, "状态");
                head.AppendFormat("Name:{{width:{0},head:'{1}',sortable:true,sortField:'{2}'}},", 200, "楼盘/门号/房号", "Community,BuildingName,Room");
                head.AppendFormat("BusinessKind:{{width:{0},head:'{1}',sortable:true}},", 40, "交易");
                head.AppendFormat("BuildingArea:{{width:{0},head:'{1}',sortable:true}},", 55, "面积");
                head.AppendFormat("SalePrice_U:{{width:{0},head:'{1}',sortable:true}},", 60, "单价(元)");
                head.AppendFormat("SalePrice_T:{{width:{0},head:'{1}',sortable:true,sortField:'{2}'}},", 65, "总价", "SalePrice_T");
                head.AppendFormat("RentPrice:{{width:{0},head:'{1}',sortable:true,sortField:'{2}'}},", 65, "租价", "SalePrice_T");
              //  head.AppendFormat("HouseStyle:{{width:{0},head:'{1}',sortable:true,sortField:'{2}'}},", 40, "房型", "Model_Room,Model_Hall,Model_Toilet");
              //  head.AppendFormat("Floor:{{width:{0},head:'{1}',sortable:true,sortField:'{2}'}},", 50, "楼层", "Cur_Floor");
                head.AppendFormat("OprDepart:{{width:{0},head:'{1}',sortable:true}},", 70, "部门");
                head.AppendFormat("OprPerson:{{width:{0},head:'{1}',sortable:true}},", 60, "业务员");
                head.AppendFormat("CustomerName:{{width:{0},head:'{1}',sortable:true}},", 70, "客户姓名");
                head.AppendFormat("CustTel1:{{width:{0},head:'{1}',sortable:true}},", 60, "客户电话");
                if ("servicetime".Equals(key[0].ToLower()))
                {
                    head.AppendFormat("ServiceTime:{{width:{0},head:'{1}',sortable:true}}", 70, "跟单时间", true);
                }
                else
                {
                    head.AppendFormat("Adddate:{{width:{0},head:'{1}',sortable:true}}", 70, "建档时间", true);
                }
                head.Append("}");
                if (!GetHouseListHtml(dshouselist, key[0], out strHtml))
                {
                    responseJson = string.Format("{{success:'0',msg:'{0}',data:''}}", "生成HTML错误");
                }
            }
            dshouselist.Dispose();
            dshouselist = null;

            responseJson = string.Format("{{success:'1',msg:'{0}',data:{{count:{1},html:'{2}',head:{3}}}}}", "成功", count, strHtml, head.ToString());
            context.Response.Write(responseJson);
        }
        catch (Exception ex)
        {
            responseJson = string.Format("{{success:'0',msg:'{0}',data:''}}", "未知错误:" + ex.Message);
            context.Response.Write(responseJson);
        }
    }

    private bool SubGetHouseListHtml(System.Data.DataSet dslist, string orderKey, out string strHtml)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        foreach (System.Data.DataRow row in dslist.Tables[0].Rows)
        {
            DateTime dt1 = Convert.ToDateTime(Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ServiceTime", ""));
            DateTime dt2 = DateTime.Now;

            TimeSpan ts = dt2.Subtract(dt1);

            if (ts.Days > Chenxin.Lib.Utility.Constants.UnTraceMaxDay && Chenxin.Lib.Utility.Constants.UnTraceMaxDay != 0)
                sb.AppendFormat("<dl id=\"{0}\" class=\"redword\">", row["HouseId"].ToString());
            else
                sb.AppendFormat("<dl id=\"{0}\">", row["HouseId"].ToString());
            //图标列
            sb.AppendFormat("<dd>{0}{1}{2}</dd>",
                (Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "IsHavekey", false)) ? "<div class=\"keyshow\" title=\"有钥匙\"></div>" : "<div class=\"keyno\" title=\"无钥匙\" ></div>",
                (Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "IsMarked", false)) ? "<div class=\"bashow\" title=\"已备案\"></div>" : "<div class=\"bano\" title=\"未备案\"></div>",
                (Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "IsProtectPhone", false)) ? "<div class=\"bhshow\" title=\"已保护\" ></div>" : "<div class=\"bhno\" title=\"未保护\" ></div>");
            //区域列
            sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0}\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Region", ""));
            //状态列
            sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0}\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Status", ""));
            //楼盘/门号/房号
            sb.AppendFormat("<dd title=\"{1}{2}{3}\"><a  href=\"ShowDetailInfo.aspx?houseid={0}\" target=\"blank\">{1} {2} {3}</a></dd>",
                                    DatasetHelper.GetValue(row, "HouseId", Guid.Empty), DatasetHelper.GetValue(row, "Community", ""),
                                    DatasetHelper.GetValue(row, "BuildingName", ""),
                                    DatasetHelper.GetValue(row, "Room", ""));
            //交易列
            sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0}\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "BusinessKind", ""));
            //面积
            sb.AppendFormat("<dd style=\"text-align:right;\" title=\"{0:f2}\">{0:f2}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "BuildingArea", ""));
            //单价
            sb.AppendFormat("<dd style=\"text-align:right;\" title=\"{0:f0}\">{0:f0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "SalePrice_U", 0f));
            //总价
            float price_t = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "SalePrice_T", 0f);
            float price_u = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "RentPrice", 0f);
            string kind = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Kind", "");
            //出售
            if ("10".Equals(kind))
            {
                sb.AppendFormat("<dd style=\"text-align:right;color:blue\" title=\"{0:f0}\">{0:f0}万</dd>", Math.Round(price_t / 10000.00));
            }
            //出租
            else if ("20".Equals(kind))
            {
                sb.AppendFormat("<dd style=\"text-align:right;color:blue\" title=\"{0:f0}\">{0:f0}元</dd>", Math.Round(price_u));
            }
            // 租售
            else
            {
                sb.AppendFormat("<dd style=\"text-align:right;color:blue\" title=\"{0:f0}\">{0:f0}万</dd>", Math.Round(price_t / 10000.00));
            }
            sb.AppendFormat("<dd style=\"text-align:right;color:blue\" title=\"{0:f0}\">{0:f0}元</dd>", Math.Round(price_u));
            //房型
           // string Model_Room = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Model_Room", "-");
           // string Model_Hall = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Model_Hall", "-");
           // string Model_Toilet = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Model_Toilet", "-");
          //  string housestyle = Model_Room + "/" + Model_Hall + "/" + Model_Toilet;
          //  sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0}\">{0}</dd>", housestyle);
            //楼层
          //  string Cur_Floor = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Cur_Floor", "-");
          //  string Total_Floor = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Total_Floor", "-");
          //  sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0}\">{0}</dd>", Cur_Floor + "/" + Total_Floor);
            //部门
            sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0}\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "OprDepart", ""));
            //业务员
            sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0}\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "OprPerson", ""));
            //客户姓名
            sb.AppendFormat("<dd  style=\"text-align:center;\" title=\"{0}\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CustomerName", ""));
            //客户电话
            //sb.AppendFormat("<dd  style=\"text-align:center;\" title=\"{0}\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CustTel1", ""));
            //跟盘时间
            if ("servicetime".Equals(orderKey.ToLower()))
            {
                sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0:yyyy-MM-dd}\">{0:yyyy-MM-dd}</dd>", Convert.ToDateTime(Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ServiceTime", "")));
            }
            else
            {
                sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0:yyyy-MM-dd}\">{0:yyyy-MM-dd}</dd>", Convert.ToDateTime(Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Adddate", "")));
            }
            sb.Append("</dl>");
            sb.Append("<input type=\"hidden\" value=\"can\" id=\"isExport\" />");
            
        }
        strHtml = sb.ToString();
        return true;
    }

    private bool GetHouseListHtml(System.Data.DataSet dslist, string orderKey, out string strHtml)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        foreach (System.Data.DataRow row in dslist.Tables[0].Rows)
        {
            DateTime dt1 = Convert.ToDateTime(Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ServiceTime", ""));
            DateTime dt2 = DateTime.Now;

            TimeSpan ts = dt2.Subtract(dt1);

            if (ts.Days > Chenxin.Lib.Utility.Constants.UnTraceMaxDay && Chenxin.Lib.Utility.Constants.UnTraceMaxDay != 0)
                sb.AppendFormat("<dl id=\"{0}\" class=\"redword\">", row["HouseId"].ToString());
            else
                sb.AppendFormat("<dl id=\"{0}\">", row["HouseId"].ToString());
            //图标列
            sb.AppendFormat("<dd>{0}{1}{2}</dd>",
                (Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "IsHavekey", false)) ? "<div class=\"keyshow\" title=\"有钥匙\"></div>" : "<div class=\"keyno\" title=\"无钥匙\" ></div>",
                (Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "IsMarked", false)) ? "<div class=\"bashow\" title=\"已备案\"></div>" : "<div class=\"bano\" title=\"未备案\"></div>",
                (Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "IsProtectPhone", false)) ? "<div class=\"bhshow\" title=\"已保护\" ></div>" : "<div class=\"bhno\" title=\"未保护\" ></div>");
            //区域列
            sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0}\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Region", ""));
            //状态列
            sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0}\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Status", ""));
            //楼盘/门号/房号
            sb.AppendFormat("<dd title=\"{1}{2}{3}\"><a  href=\"ShowDetailInfo.aspx?houseid={0}\" target=\"blank\">{1} {2} {3}</a></dd>",
                                    DatasetHelper.GetValue(row, "HouseId", Guid.Empty), DatasetHelper.GetValue(row, "Community", ""),
                                    DatasetHelper.GetValue(row, "BuildingName", ""),
                                    DatasetHelper.GetValue(row, "Room", ""));
            //交易列
            sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0}\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "BusinessKind", ""));
            //面积
            sb.AppendFormat("<dd style=\"text-align:right;\" title=\"{0:f2}\">{0:f2}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "BuildingArea", ""));
            //单价
            sb.AppendFormat("<dd style=\"text-align:right;\" title=\"{0:f0}\">{0:f0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "SalePrice_U", 0f));
            //总价
            float price_t = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "SalePrice_T", 0f);
            float price_u = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "RentPrice", 0f);
            string kind = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Kind", "");
            //出售
            if ("10".Equals(kind))
            {
                sb.AppendFormat("<dd style=\"text-align:right;color:blue\" title=\"{0:f0}\">{0:f0}万</dd>", Math.Round(price_t / 10000.00));
            }
            //出租
            else if ("20".Equals(kind))
            {
                sb.AppendFormat("<dd style=\"text-align:right;color:blue\" title=\"{0:f0}\">{0:f0}元</dd>", Math.Round(price_u));
            }
            // 租售
            else
            {
                sb.AppendFormat("<dd style=\"text-align:right;color:blue\" title=\"{0:f0}\">{0:f0}万</dd>", Math.Round(price_t / 10000.00));
            }
            sb.AppendFormat("<dd style=\"text-align:right;color:blue\" title=\"{0:f0}\">{0:f0}元</dd>", Math.Round(price_u));
            //房型
            //string Model_Room = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Model_Room", "-");
            //string Model_Hall = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Model_Hall", "-");
            //string Model_Toilet = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Model_Toilet", "-");
            //string housestyle = Model_Room + "/" + Model_Hall + "/" + Model_Toilet;
            // sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0}\">{0}</dd>", housestyle);
            //楼层
            //string Cur_Floor = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Cur_Floor", "-");
            //string Total_Floor = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Total_Floor", "-");
            //sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0}\">{0}</dd>", Cur_Floor + "/" + Total_Floor);
            //部门
            sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0}\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "OprDepart", ""));
            //业务员
            sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0}\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "OprPerson", ""));
            //客户姓名
            sb.AppendFormat("<dd  style=\"text-align:center;\" title=\"{0}\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CustomerName", ""));
            //客户电话
            sb.AppendFormat("<dd  style=\"text-align:center;\" title=\"{0}\">{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CustTel1", ""));
            //跟盘时间
            if ("servicetime".Equals(orderKey.ToLower()))
            {
                sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0:yyyy-MM-dd}\">{0:yyyy-MM-dd}</dd>", Convert.ToDateTime(Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ServiceTime", "")));
            }
            else
            {
                sb.AppendFormat("<dd style=\"text-align:center;\" title=\"{0:yyyy-MM-dd}\">{0:yyyy-MM-dd}</dd>", Convert.ToDateTime(Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Adddate", "")));
            }
            sb.Append("</dl>");
            sb.Append("<input type=\"hidden\" value=\"no\" id=\"isExport\" />");
        }
        strHtml = sb.ToString();
        return true;
    }
    private string getstring(int? status)
    {
        string str = string.Empty;
        if (status == 10)
        {
            str = "有效";
        }
        else if (status == -1)
        {
            str = "无效";
        }
        else
        {
            str = "暂缓";
        }
        return str;
    }
}